<?php
require_once '../models/PictureHandler.php';
$tempFile = $_FILES['Filedata']['tmp_name'];
$fileName = $_FILES['Filedata']['name'];
$fileSize = $_FILES['Filedata']['size'];

$userId = $_REQUEST["userId"];
$tripId = $_REQUEST["tripId"];
$placeId = $_REQUEST["placeId"];
$picture_name = $_FILES['Filedata']['name'];

//$userId = 1;
//$tripId = 99;
//$placeId = 67;
//$picture_name = "Tulips.jpg";

$structure = ".\\".$userId."\\".$tripId."\\".$placeId."\\";

if (!file_exists ( $structure ))
{ 
	mkdir($structure, 0, true); 

}

if ($_FILES['Filedata']['name'])
 {
		
		if(move_uploaded_file($_FILES['Filedata']['tmp_name'], $structure. basename($_FILES['Filedata']['name'])))		
		{
			//echo 'archivo_uploaded';			
			$picture_handler = new PictureHandler();
			$picture_handler->savePicture($userId,$tripId,$placeId,$picture_name);
		}
		
}

 
?>